#include "globalaction.h"

#include <QWidget>

GlobalAction::GlobalAction(QWidget* widget)
{
    // create
    actionCreatePage = QSharedPointer<QAction>::create(
        QIcon::fromTheme(QIcon::ThemeIcon::DocumentNew), "actionCreateFile");
    actionClosePage = QSharedPointer<QAction>::create(
        QIcon::fromTheme(QIcon::ThemeIcon::ListRemove), "actionClosePage");
    actionOpenFile = QSharedPointer<QAction>::create(
        QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen), "actionOpenFile");
    actionSaveFile = QSharedPointer<QAction>::create(
        QIcon::fromTheme(QIcon::ThemeIcon::DocumentSave), "actionSaveFile");
    actionSaveAsFile = QSharedPointer<QAction>::create(
        QIcon::fromTheme(QIcon::ThemeIcon::DocumentSaveAs), "actionSaveAsFile");

    // shortCut
    actionCreatePage->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
    actionClosePage->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_W));
    actionOpenFile->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_O));
    actionSaveFile->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
    actionSaveAsFile->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_S));

    // default connect
    widget->addAction(actionCreatePage.get());
    widget->addAction(actionClosePage.get());
    widget->addAction(actionOpenFile.get());
    widget->addAction(actionSaveFile.get());
    widget->addAction(actionSaveAsFile.get());
}
